<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>波动程序已经开启</title>
		<script src="/static/public/js/jquery.js"></script>

	</head>
	<body>
		<h1>
			波动已经打开，请勿关闭此页面。
		</h1>
		<h3 class="tips">开启时间：<em class="time">0</em></h3>
		<ul>
			
			<li class="pingcang"><b>订单平仓更新：</b>成功[<em class="success">0</em>]，失败[<em class="error">0</em>]，更新时间[<em class="time">0</em>]</li>
			<li class="fenhong"><b>代理分红计算：</b>成功[<em class="success">0</em>]，失败[<em class="error">0</em>]，更新时间[<em class="time">0</em>]</li>
		</ul>


		<script type="text/javascript">
			$(".tips .time").html(getNowFormatDate());
			
			var dataisclose = 0;
			var orderisclose = 0;
			var allotisclose = 0;
			var add_orderclose = 0;

			setInterval('ordernewisclose()', 1000);
			setInterval('allotorderisclose()', 1000);
			//********产品更新*********//
			function datanewisclose() {
				if (dataisclose == 0) {
					flash_product();
				}
			}

			function flash_product() {
				dataisclose = 1;
				$.ajax({
					url: "/index/api/getdate",
					data: "",
					type: "get",
					dataType: "text",
					beforeSend: function () {},
					success: function (e) {
						var success = $(".hangqing .success").html();
						$(".hangqing .success").html(parseInt(success) + 1);
						$(".hangqing .time").html(getNowFormatDate());
						dataisclose = 0;
					},
					error: function (e) {
						var error = $(".hangqing .error").html();
						$(".hangqing .error").html(parseInt(error) + 1);
						$(".hangqing .time").html(getNowFormatDate());
						dataisclose = 0;
					}
				});
				/*
				 
				 $.get("/index/api/getdate", {}, function () {
				 dataisclose = 0;
				 });
				 */

			}
			//********订单更新*********//
			function ordernewisclose() {
				if (orderisclose == 0) {
					flash_order();
				}
			}

			function flash_order() {
				orderisclose = 1;
				$.ajax({
					url: "/index/api/callopenposition",
					data: "",
					type: "get",
					dataType: "text",
					beforeSend: function () {},
					success: function (e) {
						var success = $(".pingcang .success").html();
						$(".pingcang .success").html(parseInt(success) + 1);
						$(".pingcang .time").html(getNowFormatDate());
						orderisclose = 0;
					},
					error: function (e) {
						var error = $(".pingcang .error").html();
						$(".pingcang .error").html(parseInt(error) + 1);
						$(".pingcang .time").html(getNowFormatDate());
						orderisclose = 0;
					}
				});
				/*
				 $.get("/index/api/order", {}, function () {
				 orderisclose = 0;
				 });
				 */
			}

			

			//********订单对冲*********//
			function allotorderisclose() {
				if (allotisclose == 0) {
					allot_order();
				}
			}

			function allot_order() {
				allotisclose = 1;
				$.ajax({
					url: "/index/api/calldividend",
					data: "",
					type: "get",
					dataType: "text",
					beforeSend: function () {},
					success: function (e) {
						var success = $(".fenhong .success").html();
						$(".fenhong .success").html(parseInt(success) + 1);
						$(".fenhong .time").html(getNowFormatDate());
						allotisclose = 0;
					},
					error: function (e) {
						var error = $(".fenhong .error").html();
						$(".fenhong .error").html(parseInt(error) + 1);
						$(".fenhong .time").html(getNowFormatDate());
						allotisclose = 0;
					}
				});

				/*
				 $.get("/index/api/allotorder", {}, function () {
				 allotisclose = 0;
				 });
				 */
			}

			//setInterval("window.location.reload();",1000*60*20);




			function getNowFormatDate() {
				var date = new Date();
				var seperator1 = "-";
				var seperator2 = ":";
				var month = date.getMonth() + 1;
				var strDate = date.getDate();
				if (month >= 1 && month <= 9) {
					month = "0" + month;
				}
				if (strDate >= 0 && strDate <= 9) {
					strDate = "0" + strDate;
				}
				var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
						+ " " + date.getHours() + seperator2 + date.getMinutes()
						+ seperator2 + date.getSeconds();
				return currentdate;
			}
		</script>
	</body>
</html>